package com.ohuang.baseapp.utils;


import ohos.aafwk.ability.AbilityPackage;
import ohos.rpc.RemoteException;


public class PackageUtil {
    public static String getVersionName(AbilityPackage context) {
        try {
            String versionName = context.getBundleManager().getBundleInfo(context.getBundleName(), 0).getVersionName();
            return versionName;
        } catch (RemoteException e) {
            e.printStackTrace();
        }
        return "";
    }

    public static String getVersionCode(AbilityPackage abilityPackage) {
        try {
            String versionName = "" + abilityPackage.getBundleManager().getBundleInfo(abilityPackage.getBundleName(), 0).getVersionCode();
            return versionName;
        } catch (RemoteException e) {
            e.printStackTrace();
        }
        return "";
    }

}
